package _01_第一季.栈与队列03;

import _01_第一季._00_公共接口.Stack;
import _01_第一季.动态数组01.ArrayList;

public class ArrayStack<E> implements Stack<E>{
    private ArrayList<E> list = new ArrayList<>();
    public ArrayStack(){

    }
    @Override
    public int size() {
        return list.size();
    }

    @Override
    public boolean isEmpty() {
        return list.isEmpty();
    }


    @Override
    public void push(E element) {
        list.add(element);
    }

    @Override
    public E pop() {
        return list.remove(list.size()-1);
    }

    @Override
    public E peek() {
        return list.get(list.size()-1);
    }

    @Override
    public void clear() {
        list.clear();
    }
}
